<?
	$this->placeholder('page_title')->set('Grants');

?>


<table class="grid" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<th>&nbsp;</th>
		<th colspan="<?= count($this->res) ?>">Resources</th>
	</tr>

<? $first = FALSE ?>
<? foreach($this->roles as $role): ?>
<? if (!$first): $first = TRUE ?>
	<tr>
		<th>Roles</th>
<? foreach($this->res as $res): ?>
		<th><?= $res->label ?></th>
<? endforeach; ?>
	</tr>
<? endif; ?>
	<tr>
		<th><?= $role->identity() ?></th>
<? foreach($this->res as $res): ?>
		<td>

<? if (!is_null($res->grant($role))): ?>
<? if ($res->grant($role) == 1): ?>
		<?= new Zupal_Control_IconLink('unlocked.gif', 'Allow', array(
			'module' => 'admin',
			'controller' => 'acl',
			'action' => 'grant',
			'role' => htmlentities($role->identity()),
			'res' => htmlentities($res->identity()),
			'mode' => 'unlocked',
			'from' => 'grants',
			'placement' => Zupal_Control_Icon::PLACEMENT_HORIZONTAL
		)) ?>
<? endif; ?>
<? if ($res->grant($role) == 0): ?>
		<?= new Zupal_Control_IconLink('locked.gif', 'Blocked', array(
			'module' => 'admin',
			'controller' => 'acl',
			'action' => 'grant',
			'role' => htmlentities($role->identity()),
			'res' => htmlentities($res->identity()),
			'mode' => 'locked',
			'from' => 'grants',
			'placement' => Zupal_Control_Icon::PLACEMENT_HORIZONTAL
		)) ?>
<? endif; ?>
<br clear="all" /><?= new Zupal_Control_IconLink('x.gif', 'Clear', array(
			'module' => 'admin',
			'controller' => 'acl',
			'action' => 'grant',
			'role' => htmlentities($role->identity()),
			'res' => htmlentities($res->identity()),
			'mode' => 'delete',
			'from' => 'grants',
			'placement' => Zupal_Control_Icon::PLACEMENT_HORIZONTAL
		)) ?>
<? else: ?>
		<?= new Zupal_Control_IconLink('add.gif', 'Set', array(
			'module' => 'admin',
			'controller' => 'acl',
			'action' => 'grant',
			'role' => htmlentities($role->identity()),
			'res' => htmlentities($res->identity()),
			'mode' => 'choose',
			'from' => 'grants',
			'placement' => Zupal_Control_Icon::PLACEMENT_HORIZONTAL
		)) ?>
<? endif; ?>
		</td>
<? endforeach; ?>
	</tr>
<? endforeach; ?>
</table>